<script >
$(document).ready(function(){
	$("#dstart, #dend").datepicker({
		dateFormat : "yy-mm"
	});
});
</script>
<style >
table.data tr td,table.data tr th{ font-size: 10px;}
</style>
<form style="padding:5px; width:100%;" id="frm-search" method="post" class="cari" action="<?php echo $own_links;?>search">
	<input type="hidden" name="column" value="all" />
	<img src="<?php echo themeUrl();?>images/cari.png" align="left" />
	<input type="hidden" name="keyword" value=""/>
    Pilih Nama Client : <select name="column" id="column">
		<?php cat_search($cat_search);?>
    </select>
	Pilih Periode : 
	<input type="text" id="dstart" name="dstart" value="<?php echo $this->jCfg['isearch']['start_date'];?>" size="8" /> s/d 
	<input type="text" name="dend" id="dend" value="<?php echo $this->jCfg['isearch']['end_date'];?>" size="8"/>
	<input type="submit" name="cari" class="btn-cari" value="Cari" />
	<input type="button" onclick="document.location='<?php echo modUri()."transaksi/report_excel/";?>'" name="reset" class="btn-reset" value="Reset" />
	<?php if(isset($data) && count($data) > 0){ ?>
		<input type="button" name="download-excel" id="donlot'" onclick="_getExcel()" class="btn-cari" value="Download Excel" />
	<?php } ?>
</form>
<div class="clr"></div>
<?php echo isset($paging)?$paging:'';?>
<div class="clr"></div>
<?php if(isset($items) && count($items) > 0){ ?>
<div style=" padding:4px; background-color:#FF9; border:2px solid #FC3; margin-bottom:5px; font-size:14px;">
<h2 style="font-size:15px; float:left;">Total Data : <?php echo count($items);?> data</h2>
<?php
	$jumlah = 0;
	foreach($items as $m){
		$jumlah += $m->detail_sub_premi;
	}
?>
<h2 style="font-size:15px; float:right;">Total Premi : <?php echo myNum($jumlah);?></h2>
<div class="clr"></div>
</div>
<div class="clr"></div>
<?php } ?>
<table class="data">
	<tr>
		<th>No</th>  
		<th>Bulan</th>
        <th>Nama</th>
        <th>Alamat</th>
        <th>Tgl Lahir</th>
        <th>Tgl Akad</th>
        <th>Usia</th>
        <th>Periode Pertanggungan</th>
        <th>Jangka Waktu < 65 thn</th>
        <th>Jangka Waktu > 65 thn</th>   
        <th>Premi Usia 40-65</th>   
        <th>Premi Usia 66-75</th> 
        <th>Nilai Kredit</th>      
        <th>Premi</th>
	</tr>
    <?php if(isset($data) && count($data) > 0){
			$no=1;
			foreach($data as $r){
		?>
     		<tr>
            	<td><?php echo $no++;?></td>
                <td><?php echo $r->kd_bulan;?></td>
                <td><?php echo $r->detail_nama;?></td>
                <td><?php echo $r->detail_alamat;?></td>
                <td><?php echo myDate($r->detail_tgllahir,"d/m/Y",false);?></td>
                <td><?php echo myDate($r->detail_tglakad,"d/m/Y",false);?></td>
                <td align="center"><?php echo $r->detail_usia;?> Thn</td>
                <td align="center"><?php echo $r->detail_periode_tgj;?> Thn</td>
                <td align="center"><?php echo $r->detail_jwp1;?> Thn</td>
                <td align="center"><?php echo $r->detail_jwp2;?> Thn</td>
                <td><?php echo myNum($r->detail_rate_pu1);?></td>
                <td><?php echo myNum($r->detail_rate_pu2);?></td>
                <td><?php echo myNum($r->detail_nilai_kredit);?></td>
                <td><?php echo myNum($r->detail_sub_premi);?></td>
            </tr>   
    <?php } 
	}
	?>
</table>

<?php echo isset($paging)?$paging:'';?>

<script language="javascript">
function _getExcel(){
	col = $('#column').val();
	ds 	= ( $.trim($('#dstart').val()) == "" )?"all":$.trim($('#dstart').val());
	de 	= ( $.trim($('#dend').val()) == "" )?"all":$.trim($('#dend').val());
	url_go = "<?php echo $own_links;?>get_excel/"+col+"/"+ds+"/"+de;
	document.location = url_go;
}

$('.item_submit').change(function(){
	$('#frm-search').submit();
});
</script>